% note: aafDataFromServer is a matrix with 2 columns. The first is the
% event type, the second is the timestamp in milliseconds (the zero here is
% when the mote was powered)
%
function ComputeFeaturesVersion2( tLabviewEvent, aafEvent )
	%
	% find the index of the various events
	iIndexOfFirstDoorOpenTime		= find(aafEvent(:,1)==1, 1, 'first');
	iIndexOfFirstLaser1OpenTime		= find(aafEvent(:,1)==3, 1, 'first');
	iIndexOfFirstLaser2OpenTime		= find(aafEvent(:,1)==5, 1, 'first');
%  	iIndexOfFirstDoorCloseTime		= find(aafEvent(:,1)==2, 1, 'first');
% 	iIndexOfFirstLaser1CloseTime	= find(aafEvent(:,1)==4, 1, 'first');
% 	iIndexOfFirstLaser2CloseTime	= find(aafEvent(:,1)==6, 1, 'first');
	
% 	iIndexOfLastDoorOpenTime		= find(aafEvent(:,1)==1, 1, 'last');
% 	iIndexOfLastLaser1OpenTime		= find(aafEvent(:,1)==3, 1, 'last');
% 	iIndexOfLastLaser2OpenTime		= find(aafEvent(:,1)==5, 1, 'last');
	iIndexOfLastDoorCloseTime		= find(aafEvent(:,1)==2, 1, 'last');
	iIndexOfLastLaser1CloseTime  	= find(aafEvent(:,1)==4, 1, 'last');
	iIndexOfLastLaser2CloseTime	    = find(aafEvent(:,1)==6, 1, 'last');
	%
	% find the timestamps of the events
	fFirstDoorOpenTime		= aafEvent(iIndexOfFirstDoorOpenTime, 2);
	fFirstLaser1OpenTime	= aafEvent(iIndexOfFirstLaser1OpenTime, 2);
	fFirstLaser2OpenTime	= aafEvent(iIndexOfFirstLaser2OpenTime, 2);
% 	fFirstDoorCloseTime		= aafEvent(iIndexOfFirstDoorCloseTime, 2);
% 	fFirstLaser1CloseTime	= aafEvent(iIndexOfFirstLaser1CloseTime, 2);
% 	fFirstLaser2CloseTime	= aafEvent(iIndexOfFirstLaser2CloseTime, 2);
	%
% 	fLastDoorOpenTime		= aafEvent(iIndexOfLastDoorOpenTime, 2);
% 	fLastLaser1OpenTime	    = aafEvent(iIndexOfLastLaser1OpenTime, 2);
% 	fLastLaser2OpenTime	    = aafEvent(iIndexOfLastLaser2OpenTime, 2);
	fLastDoorCloseTime		= aafEvent(iIndexOfLastDoorCloseTime, 2);
	fLastLaser1CloseTime	= aafEvent(iIndexOfLastLaser1CloseTime, 2);
	fLastLaser2CloseTime	= aafEvent(iIndexOfLastLaser2CloseTime, 2);
	%
    % find the passing times of laser 1 and laser 2 
	iPassingtimesLaser1     = sum(aafEvent(:,1)==3)*1000;
	iPassingtimesLaser2     = sum(aafEvent(:,1)==5)*1000;
	% compute the features
	tLabviewEvent.afFeatures =										...
		[	fFirstLaser1OpenTime - fFirstDoorOpenTime,		...
			fFirstLaser2OpenTime - fFirstDoorOpenTime,		...			
			fLastDoorCloseTime   - fFirstDoorOpenTime,		...
			fLastLaser1CloseTime - fFirstDoorOpenTime,		...
			fLastLaser2CloseTime - fFirstDoorOpenTime,		... 
			iPassingtimesLaser1,                            ...
			iPassingtimesLaser2                             ...
			                                                  ];
	%
	% check if the event is a valid one, i.e., if we saw all the data
	if( numel(tLabviewEvent.afFeatures) < 7 )
		%
		tLabviewEvent.bIsValid = false;
		%
	else%
		%
		tLabviewEvent.bIsValid = true;
		%
	end;%
	%
end %function

%           fFirstDoorOpenTime - fFirstDoorCloseTime,		...    
% 			fFirstDoorOpenTime - fFirstLaser1CloseTime,		...
% 			fFirstDoorOpenTime - fFirstLaser2CloseTime	    ...
% 			fFirstDoorOpenTime - fLastDoorOpenTime,         ...
% 			fFirstDoorOpenTime - fLastLaser1OpenTime,		...
% 			fFirstDoorOpenTime - fLastLaser2OpenTime,		...